<?php
session_start();
require_once "include/database.php";
$db = db_connect();
require_once "include/auth.php";
$current_user = current_user();
require_login();
require_user(0);
$title = "CS 4400 Project | Tutor Logbook";
include "_header.php"; 

$tutor_code_query = $db->prepare("SELECT Code
FROM course_code AS cc
JOIN tutors_for AS tf ON cc.Course_Title = tf.Course_Title
WHERE tf.Tutor_Student_ID =:studentid");

$tutor_code_query->execute(array("studentid" => $current_user['studentid']));
?>

<link href="bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet">

<div class="container">

  <form action="logbooksubmit.php" method="POST" style="text-align:center">
    <h2 class="form-signin-heading">Tutor Logbook</h2>
    <?php if($_GET['error'] == '1'): ?>
    	<h4 class="text-error">Incorrect Student ID!</h4>
    <?php endif; ?>
    <?php if($_GET['success'] == '1'): ?>
      <h4 class="text-success">You've added the user successfully!</h4>
    <?php endif; ?>
	<select name='dropdown_code'>
    <?php
    while($result = $tutor_code_query->fetch()) {
      echo "<option value='" . $result['Code'] . "'>" . $result['Code'] . "</option>";
    }
    ?>
    </select>
    </br><input type="text" style="width:220px" placeholder="Student ID" name="studentid" id="studentid">
    </br><button class="btn btn-large btn-primary" type="submit">Submit</button>
  </form>

</div>